<?php
require 'db.php';
require 'function.php';
$action = isset($_GET['a'])?$_GET['a']:'index';
switch ($action) {
	case 'index':
		$data = select("select * from news n join project p on n.cid=p.id order by addtime desc");
		include 'view/index.html';
		break;
	case 'add':
	// echo 'ok';exit;
		$projects = select("select * from project");
		$projects = categoryTree($projects);
		// p($prgjects);exit;
		include 'view/add.html';
		break;
	case 'doadd':
		$title = $_POST['title'];
		$content =$_POST['content'];
		$addtime =time();
		$cid = $_POST['cid'];
		$click=100;
		execute("INSERT INTO news(title,content,addtime,click,cid) VALUES('$title','$content',$addtime,$click,$cid)");
		header('location:index.php');
		break;
	default:
		
		break;
}


?>